package com.aoasaa;

import com.sendingFBpost.FBAppActivity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

public class UploadingImageNotes extends Activity{
	public EditText contents;
	public SharedPreferences sp_obj;
	public Editor editor_obj;
	@Override
	public void onCreate(Bundle  savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.imageuploadingscreen); 
		
		// accessing shared preference     
		sp_obj=getSharedPreferences("ArchiveApp",MODE_WORLD_WRITEABLE);
		editor_obj=sp_obj.edit(); 
		
		EditText category=(EditText)findViewById(R.id.editText_imgcategory);
		category.setText(sp_obj.getString("selectedfilecategory", "").toString());
		
		EditText title=(EditText)findViewById(R.id.editText_finalimgtag);
		title.setText(sp_obj.getString("selectedfiletitle", "").toString());
		
		Uri path = Uri.parse(sp_obj.getString("uploadsessionfileurl", "no url"));
		
		ImageView img=(ImageView)findViewById(R.id.img_finalimage);
		img.setImageURI(path);
		// creating reference for save button    

		Button save=(Button)findViewById(R.id.btn_imagesave);
		save.setOnClickListener(new View.OnClickListener() {
   
			@Override 
			public void onClick(View v) {
				// creating reference for controls
				
				contents=(EditText)findViewById(R.id.edittext_imagenotes);
				
				//storing values in shared preference
				
				editor_obj.putString("selectedfilenotes", contents.getEditableText().toString());
               // editor_obj.commit(); 
				// adding preference variable for checking saving or sharing
				  
				editor_obj.putString("checkingSAVEorFB", "SAVE");
				editor_obj.commit();
             
				// using intent to navigate to uploading activity
				
				Intent obj=new Intent(UploadingImageNotes.this,UploadingDocumentTOPHP.class);
				startActivity(obj); 
			} 
		});

		// SHARE Button reference i.e, sharing note on face book

		Button share=(Button)findViewById(R.id.btn_imageshare);
		share.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) { 
				// creating reference for controls 
				//title=(EditText)findViewById(R.id.et_textag);
				contents=(EditText)findViewById(R.id.et_textnote);
				
				// adding preference variable for checking saving or sharing
				  
				editor_obj.putString("checkingSAVEorFB", "FB");
				editor_obj.putString("check_FBnotestype", "image");
				editor_obj.commit();
				
               // using intent to navigate to uploading activity
				
				Intent obj=new Intent(UploadingImageNotes.this,UploadingDocumentTOPHP.class);
				startActivity(obj); 
				
//				// FB LOGIC
//				
//				String usermessage=sp_obj.getString("selectedfiletitle", "")+" \n "+contents.getEditableText().toString();
//				
//				Intent intent = new Intent(UploadingImageNotes.this,FBAppActivity.class);
//			    intent.putExtra("facebookMessage", usermessage);
//			    startActivity(intent); 
				

			}
		});
	}
}